package com.aat.func;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;

public class SysinfoTest {
	public void test(HttpServletRequest request) {
		Properties props = System.getProperties();
		// java版本
		String javaVersion = props.getProperty("java.version");
		// 操作系统名称
		String osName = props.getProperty("os.name") + props.getProperty("os.version");
		// 用户的主目录
		String userHome = props.getProperty("user.home");
		// 用户的当前工作目录
		String userDir = props.getProperty("user.dir");
		// 服务器IP
		String serverIP = request.getLocalAddr();
		// 客户端IP
		String clientIP = request.getRemoteHost();
		// WEB服务器
		String webVersion = request.getServletContext().getServerInfo();
		// CPU个数
		String cpu = Runtime.getRuntime().availableProcessors() + "核";
		// 虚拟机内存总量
		String totalMemory = (Runtime.getRuntime().totalMemory() / 1024 / 1024) + "M";
		// 虚拟机空闲内存量
		String freeMemory = (Runtime.getRuntime().freeMemory() / 1024 / 1024) + "M";
		// 虚拟机使用的最大内存量
		String maxMemory = (Runtime.getRuntime().maxMemory() / 1024 / 1024) + "M";
		// 网站根目录
		String webRootPath = request.getSession().getServletContext().getRealPath("");
		System.out.println(javaVersion);
		System.out.println(osName);
		System.out.println(userHome);
		System.out.println(userDir);
		System.out.println(serverIP);
		System.out.println(clientIP);
		System.out.println(webVersion);
		System.out.println(cpu);
		System.out.println(totalMemory);
		System.out.println(freeMemory);
		System.out.println(maxMemory);
		System.out.println(webRootPath);
	}
}
